package com.ews.onlineexchange.service;

import java.util.List;

import javax.enterprise.inject.Model;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import com.ews.onlineexchange.model.Complaint;

@Model
public class ComplaintSearchList extends EntityQuery<Complaint> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Boolean handled;

	public ComplaintSearchList() {
		setOrder("createDate DESC");
	}

	@Override
	protected List<Predicate> getRestrictions(CriteriaBuilder cb, Root<Complaint> entity) {	
		List<Predicate> restrictions = super.getRestrictions(cb, entity);		
		Object seqNo = getParameterValues().get("seqNo");
		if (seqNo != null)
			restrictions.add(cb.equal(entity.get("seqNo"), seqNo.toString()));
		else
			restrictions.add(cb.equal(entity.get("seqNo"), ""));
		return restrictions;
	}

	public Boolean getHandled() {
		return handled;
	}

	public void setHandled(Boolean handled) {
		this.handled = handled;
	}

}
